//
//  ExhibitionProfileCell.m
//  ppkc2016
//
//  Created by 拼凑的断音 on 16/3/28.
//  Copyright © 2016年 拼凑的断音. All rights reserved.
//

#import "ExhibitionProfileCell.h"
#import "XXTool.h"

@interface ExhibitionProfileCell ()

@property (nonatomic) UILabel *titleLabel;

@property (nonatomic) UILabel *contentLabel;

@property (nonatomic) UIView *line;

@end

@implementation ExhibitionProfileCell

-(UILabel*)titleLabel
{
    if (_titleLabel==nil)
    {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = [XXTool colorWithHexString:@"3A3A3A"];
        _titleLabel.font = [XXTool systemFontOfSize:14];
        _titleLabel.numberOfLines = 0;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}

-(UILabel*)contentLabel
{
    if (_contentLabel==nil)
    {
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.textColor = [XXTool colorWithHexString:@"989898"];
        _contentLabel.font = [XXTool systemFontOfSize:14];
        _contentLabel.textAlignment = NSTextAlignmentCenter;
        _contentLabel.numberOfLines = 0;
        [self addSubview:_contentLabel];
    }
    return _contentLabel;
}

-(UIView*)line
{
    if (_line==nil)
    {
        _line = [[UIView alloc] init];
        _line.backgroundColor = [XXTool colorWithHexString:@"CBCBCB"];
        [self addSubview:_line];
    }
    return _line;
}

-(void)initParameter
{

}

-(void)initUI
{
    [self titleLabel];
    [self contentLabel];
    [self line];
}

-(void)refreshLayout:(CGRect)frame
{
    _titleLabel.frame = CGRectMake(0
                                   , 0
                                   , frame.size.width
                                   , 72);
    _contentLabel.frame = CGRectMake(10
                                     , _titleLabel.frame.size.height+_titleLabel.frame.origin.y
                                     , frame.size.width-20
                                     , [XXTool getTextHeightByText:_contentLabel.text
                                                              Font:_contentLabel.font
                                                             Width:frame.size.width-20]);
    _line.frame = CGRectMake(20
                             , _contentLabel.frame.size.height+_contentLabel.frame.origin.y+24.5
                             , frame.size.width-40
                             , 0.5);
}

-(void)setcellWithExhibitionProfileData:(ExhibitionProfileShowTitleModel *)data
{
    _titleLabel.text = data.mode_title;
    if ([data.model_type intValue]==3)
    {
        NSMutableAttributedString *content = [[NSMutableAttributedString alloc] initWithString:data.mode_content];
        [content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, content.length)];
        _contentLabel.attributedText = content;
    }
    else
    {
        _contentLabel.text = data.mode_content;
    }
    [self refreshLayout:self.frame];
}

+(CGFloat)getHeightForExhibitionProfileCell:(ExhibitionProfileShowTitleModel *)data
{
    return 72+[XXTool getTextHeightByText:data.mode_content
                                     Font:[XXTool systemFontOfSize:14]
                                    Width:[UIScreen mainScreen].bounds.size.width-20]+25;
}

@end
